package com.sqx.modules.scFollow.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.goods.entity.Goods;
import com.sqx.modules.goods.service.GoodsService;
import com.sqx.modules.scFollow.entity.ScFollow;
import com.sqx.modules.scFollow.service.ScFollowService;
import com.sqx.modules.tbOrders.entity.TbOrders;
import com.sqx.modules.tbOrders.service.TbOrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/scFollow")
@Api(value = "收藏|关注-管理端", tags = {"收藏|关注-管理端"})
public class ScFollowController {
    @Autowired
    private ScFollowService scFollowService;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private TbOrdersService tbOrdersService;

    @ApiOperation("后台管理端查看我的足迹列表")
    @GetMapping("selectMyFootprintList")
    public Result selectMyFootprintList(@ApiParam("用户id")Long userId,
                                        @ApiParam("页码") Integer pageNum,
                                        @ApiParam("条数") Integer pageSize) {
        return scFollowService.selectMyFootprintLists(userId, pageNum, pageSize);
    }


    @ApiOperation("查看我关注的用户列表")
    @GetMapping("getFollowList")
    public Result getFollowList(@ApiParam("用户id")Long userId,
                                @ApiParam("页码") Integer pageNum,
                                @ApiParam("条数") Integer pageSize) {
        return scFollowService.getFollowList(userId, pageNum, pageSize);
    }


    @ApiOperation("查看我的粉丝列表,isMutualFollow为0是单向关注(即回关)，1是互相关注")
    @GetMapping("getFanList")
    public Result getFanList(@ApiParam("用户id")Long userId,
                             @ApiParam("页码") Integer pageNum,
                             @ApiParam("条数") Integer pageSize) {
        return scFollowService.getFanList(userId, pageNum, pageSize);
    }
    @ApiOperation("获取我的收藏|想要列表")
    @GetMapping("getFollowGoodsList")
    public Result getFollowGoodsList(@ApiParam("用户id")Long userId,
                                     @ApiParam("页码")Integer page,
                                     @ApiParam("条数")Integer limit,
                                     @ApiParam("商品收藏、商品想要、关注用户、收藏动态实体")ScFollow follow){
        return Result.success().put("data", scFollowService.getFollowGoodsList(userId,page,limit,follow));
    }

    @ApiOperation("获取我收藏的动态列表")
    @GetMapping("selectByMyCollect")
    public Result selectByMyCollect(@ApiParam("用户id")Long userId,
                                    @ApiParam("页码")Integer page,
                                    @ApiParam("条数")Integer limit,
                                    @ApiParam("商品收藏、商品想要、关注用户、收藏动态实体")ScFollow follow){
        return Result.success().put("data", scFollowService.selectByMyCollect(userId,page,limit,follow));
    }

    /**
     * 获取我的商品列表
     * @param goods 商品
     */
    @ApiOperation("获取我发布的商品列表")
    @GetMapping(value = "getMyGoodsList")
    public Result getMyGoodsList(@ApiParam("用户id")Long userId,
                                 @ApiParam("页码")Integer page,
                                 @ApiParam("条数")Integer limit,
                                 @ApiParam("商品实体")Goods goods) {
        goods.setUserId(userId);
        return Result.success().put("data", goodsService.getMyGoodsList(page, limit, goods));
    }

    /**
     * 获取我买入的订单列表
     */
    @GetMapping("/getAppTbOrdersList")
    @ApiOperation("获取我买入的订单列表")
    public Result getAppTbOrdersList(@ApiParam("用户id")Long userId,
                                     @ApiParam("页码")Integer page,
                                     @ApiParam("条数")Integer limit,
                                     @ApiParam("订单实体")TbOrders tbOrders) {
        tbOrders.setBuyerId(userId);
        return tbOrdersService.getAppTbOrdersList(page, limit, tbOrders);
    }

    /**
     * 获取我卖出的订单列表
     * @param userId
     * @param page
     * @param limit
     * @param tbOrders
     * @return
     */
    @GetMapping("/getTbOrdersList")
    @ApiOperation("获取我卖出的订单列表")
    public Result getTbOrdersList(@ApiParam("用户id")Long userId,
                                  @ApiParam("页码")Integer page,
                                  @ApiParam("条数")Integer limit,
                                  @ApiParam("订单实体")TbOrders tbOrders) {
        tbOrders.setSellerId(userId);
        return tbOrdersService.getTbOrdersList(page, limit, tbOrders);
    }

}
